package agent;

import util.JVMMetric;

import java.lang.instrument.Instrumentation;
import java.util.concurrent.*;

/**
 * @author: Alan
 * @date: 2021/4/25 22:22
 */
public class MyAgentJVM {

    public static void premain(String agentArgs, Instrumentation inst){
        System.out.println("this is an perform monitor agent.");

        ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(1);
        scheduledThreadPoolExecutor.scheduleAtFixedRate(new Runnable() {
            @Override
            public void run() {
                JVMMetric.printMemoryInfo();
                JVMMetric.printGCInfo();
            }
        },0,5000, TimeUnit.MILLISECONDS);

    }

}
